package com.ruoyi.college.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.college.domain.LabOrgKinds;
import com.ruoyi.college.service.ILabOrgKindsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构分类Controller
 * 
 * @author winner pan
 * @date 2022-02-13
 */
@RestController
@RequestMapping("/college/orgKinds")
public class LabOrgKindsController extends BaseController
{
    @Autowired
    private ILabOrgKindsService labOrgKindsService;

    /**
     * 查询机构分类列表
     * 公用基础数据，不加权限
     */
    //@PreAuthorize("@ss.hasPermi('college:orgKinds:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabOrgKinds labOrgKinds)
    {
        startPage();
        List<LabOrgKinds> list = labOrgKindsService.selectLabOrgKindsList(labOrgKinds);
        return getDataTable(list);
    }

    /**
     * 导出机构分类列表
     */
    @PreAuthorize("@ss.hasPermi('college:orgKinds:export')")
    @Log(title = "机构分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabOrgKinds labOrgKinds)
    {
        List<LabOrgKinds> list = labOrgKindsService.selectLabOrgKindsList(labOrgKinds);
        ExcelUtil<LabOrgKinds> util = new ExcelUtil<LabOrgKinds>(LabOrgKinds.class);
        return util.exportExcel(list, "OrgKinds");
    }

    /**
     * 获取机构分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('college:orgKinds:query')")
    @GetMapping(value = "/{orgKindId}")
    public AjaxResult getInfo(@PathVariable("orgKindId") Long orgKindId)
    {
        return AjaxResult.success(labOrgKindsService.selectLabOrgKindsById(orgKindId));
    }

    /**
     * 新增机构分类
     */
    @PreAuthorize("@ss.hasPermi('college:orgKinds:add')")
    @Log(title = "机构分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabOrgKinds labOrgKinds)
    {
        return toAjax(labOrgKindsService.insertLabOrgKinds(labOrgKinds));
    }

    /**
     * 修改机构分类
     */
    @PreAuthorize("@ss.hasPermi('college:orgKinds:edit')")
    @Log(title = "机构分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabOrgKinds labOrgKinds)
    {
        return toAjax(labOrgKindsService.updateLabOrgKinds(labOrgKinds));
    }

    /**
     * 删除机构分类
     */
    @PreAuthorize("@ss.hasPermi('college:orgKinds:remove')")
    @Log(title = "机构分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orgKindIds}")
    public AjaxResult remove(@PathVariable Long[] orgKindIds)
    {
        return toAjax(labOrgKindsService.deleteLabOrgKindsByIds(orgKindIds));
    }
}
